﻿<html DIR="LTR" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
  <head>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8" />
    <META NAME="save" CONTENT="history" />
    <title>Readme For Ascmd Command-line Utility Sample</title>
    
 <Style TYPE="text/css">

body
{
    background: #FFFFFF;
    color: #000000;
    font-family:    Verdana;
    font-size: medium;
    font-style: normal;
    font-weight: normal;
    margin-top: 0;
    margin-bottom:  0;
    margin-left:    0;
    margin-right:   0;
    width:  100%;
}

div.#mainSection
{
    font-size: 70%;
    width: 100%;
    padding-left:    10;
    margin-right: 10;
}

div.#mainBody
{
    font-size: 90%;
    margin-top: 10;
    padding-bottom: 20;
}

div.#header
{
    background-color: #D2D2D2;
    padding-top:    0;
    padding-bottom: 0;
    padding-left:   10;
    padding-right:  0;
    width:          100%;
}

div.#header table
{
    border-bottom-color: #C8CDDE;
    border-bottom-style: solid;
    border-bottom-width: 1;
    width:  100%;
}

span.#runningHeaderText
{
    color: #003399;
    font-size: 90%;
}

span.#nsrTitle
{
/*    color: #003399;*/
    font-size: 120%;
    font-weight: 600;
}

div.#header table td
{
    color: #000000;
    font-size: 70%;
    margin-top: 0;
    margin-bottom:  0;
    padding-right: 20;
}

div.#header table tr.#headerTableRow3 td
{
    padding-bottom: 2;
    padding-top: 5;
}

div.#header table.#bottomTable
{
    border-top-color: #FFFFFF;
    border-top-style: solid;
    border-top-width: 1;
    text-align: left;
}

div.#footer
{
    font-size: 90%;
    margin-top: 0;
    margin-bottom:  0;
    margin-left:    -5;
    margin-right:   0;
    padding-top:    2;
    padding-bottom: 2;
    padding-left:   0;
    padding-right:  0;
    width:  100%;
}

hr.#footerHR
{
    border-bottom-color: #EEEEFF;
    border-bottom-style: solid;
    border-bottom-width: 1;
    border-top-color: C8CDDE;
    border-top-style: solid;
    border-top-width: 1;
    height: 3;
    color: #D2D2D2;
}

div.section
{
    padding-top:    2;
    padding-bottom: 2;
    padding-right:  15;
    width:  100%;
}

.heading
{
    color:          #000000;
    font-weight:    bold;
    margin-top:     18;
    margin-bottom:  8;
}

h1.heading
{
    color: #000000;
    font-size:  150%;
}

.subHeading
{
    color:          #000000;
    font-weight:    bold;
    font-size:      150%;
    margin-bottom:  4;
}

h2.subHeading
{
    color:          #000000;
    font-weight:    bold;
    font-size:      130%;
}
h3.subHeading
{
    color:  #000000;
    font-size: 125%;
    font-weight: bold;
}

h4.subHeading
{
    color: #000000;
    font-size: 110%;
    font-weight: bold;
}

h4.procedureHeading
{
    color: #000080;
    font-size: 110%;
    font-weight: bold;
}

h5.subHeading
{
    color: #000000;
    font-size: 100%;
    font-weight: bold;
}

img
{
    padding-bottom: 10;
}

img.toggle
{
    border: 0;
    margin-right: 5;
    padding-bottom: 10;
}

img.copyCodeImage
{
    border: 0;
    margin: 1;
    margin-right: 3;
    padding-bottom: 10;
}

img.downloadCodeImage
{
    border: 0;
    margin-right: 3;
    padding-bottom: 10;
}

img.viewCodeImage
{
    border: 0;
    margin-right: 3;
    padding-bottom: 10;
}

img.note
{
    border: 0;
    margin-right: 3;
    padding-bottom: 10;
}

img.#membersOptionsFilterImage
{
    border: 0;
    margin-left: 10;
    vertical-align: middle;
    padding-bottom: 10;
}

img.#toggleAllImage
{
    margin-left: 4;
    vertical-align: middle;
    padding-bottom: 10;
}

div.#mainSection table
{
    border: 0;
    font-size: 100%;
    width:  100%;
    margin-top: 5px;
    margin-bottom: 15px;
}

div.#mainSection table tr
{
    vertical-align: top;
}

div.#mainSection table th
{
    text-align: left;
    background: #D8D8D8;
    border-bottom-color: #D8D8D8;
    border-bottom-style: solid;
    border-bottom-width: 1;
    color: #000000;
    padding-left: 5;
    padding-right: 5;
}

div.#mainSection table td
{
    background: #F2F2F2;
    border-top-color: #D8D8D8;
    border-top-style: solid;
    border-top-width: 1;
    padding-left: 5;
    padding-right: 5;
}

div.#mainSection table td.imageCell
{
    white-space: nowrap;
}

div.code
{
	width: 98%;
}

div.code table
{
    border: 0;
    font-size: 95%;
    margin-bottom: 5;
    width: 100%
}

div.code table th
{   
    text-align: left;
    background: #D8D8D8;
    border-bottom-color: #D8D8D8;
    border-bottom-style: solid;
    border-bottom-width: 1;
    color: #000000;
    font-weight: bold;
    padding-left: 5;
    padding-right: 5;
}

div.code table td
{
    background: #CCCCCC;
    border-top-color: #D8D8D8;
    border-top-style: solid;
    border-top-width: 1;
    padding-left: 5;
    padding-right: 5;
    padding-top: 5;
}

div.alert
{
	margin-left: 10;
	width: 98%;
}

div.alert table
{
    border: 1;
    font-size: 100%;
    width:  100%;
    border: solid 1 #DEDFEF;
}

div.alert table th
{
    text-align: left;
    background: #D8D8D8;
    border-bottom-width: 0;
    color: #000000;
    padding-left: 5;
    padding-right: 5;
    border: solid 1 #DEDFEF;
}

div.alert table td
{
    background: #FFFFFF;
    border-top-color: #D8D8D8;
    border-top-style: solid;
    border-top-width: 1;
    padding-left: 5;
    padding-right: 5;
    border: solid 1 #DEDFEF;
}

span.copyCode
{
    color: #0000ff;
    font-size: 90%;
    font-weight: normal;
    cursor: hand;
    float: right;
    display: inline;
    text-align: right;
}

.downloadCode
{
    color: #0000ff;
    font-size: 90%;
    font-weight: normal;
    cursor: hand;
}

.viewCode
{
    color: #0000ff;
    font-size: 90%;
    font-weight: normal;
    cursor: hand;
}

div.code pre
{
    font-family:    Monospace, Courier New, Courier;
    font-size: 105%;
    color:  #000000;
}

code
{
    font-family:    Monospace, Courier New, Courier;
    font-size: 105%;
    color:  #000000;
}

dl
{
    margin-top: 0;
    padding-left:   1;
}

dd
{
    margin-bottom:  0;
    margin-left:    0;
    padding-left:   20;
}

dd p
{
    margin-top: 5;
}

ul
{
    margin-left: 17;
    list-style-type: disc;
}

ul ul
{
    margin-bottom: 4;
    margin-left: 17;
    margin-top: 3;
    list-style-type: disc;
}

ol
{
    margin-left: 24;
    list-style-type: decimal;
}

ol ol
{
    margin-left: 24;
    margin-top: 3;
    list-style-type: lower-alpha;
}

li
{
    margin-top: 0;
    margin-bottom: 0;
    padding-bottom: 0;
    padding-top: 0;
    margin-left: 5;
}

p
{
    margin-bottom: 15;
}

.tip
{
    color:  #0000FF;
    font-style: italic;
    cursor:hand;
    text-decoration:underline;
}

.math
{
    font-family: Times New Roman;
    font-size: 125%
}
.sourceCodeList
{
    font-family: Verdana;
    font-size: 90%; 
}

pre.viewCode
{
    width: 100%;
    overflow: auto;
}

li:hover table, li.over table
{
    background-color: #C0C0C0;
}

li:hover ul, li.over ul
{ 
    background-color: #d2d2d2;
    border: 1px solid #000;
    display: block;
}

</style>
  </head>
  <body>
    <!--Topic built:4/2/2007-->

    <div id="header">
      <table width="100%" id="topTable">
        <tr>
          <td align="left">
            <span id="nsrTitle">Readme For Ascmd Command-line Utility Sample</span>
          </td>
          
              
        </tr>
      </table>
      </div>
    <div id="mainSection">
      <div id="mainBody">

        <font color="DarkGray">[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.] </font><p /> 
        <span id="changeHistory">
        </span>
    <p>
      This sample works only with SQL Server 2005 and SQL Server "Katmai". It will not work with any version of SQL Server earlier than SQL Server 2005.
    </p>
    <p>The <b>ascmd</b> command-line utility enables a database administrator to execute an XMLA script, MDX query, or DMX statement against an instance of Microsoft Analysis Services. This command-line utility contains functionality for Analysis Services that resembles the <b>sqlcmd</b> utility included with SQL Server. For more information, see the topic <b>sqlcmd Utility</b> in SQL Server. The execution results of the script, query, or statement can be stored in a file together with relevant SQL Server Profiler trace information. The default install location for the <b>ascmd</b> command-line utility is as follows:</p>
    <p>
      C:\Program Files\Microsoft SQL Server\100\Samples\Analysis Services\Administrator\ascmd</p>
  <h1 class="heading">Scenarios</h1><div id="sectionSection0" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">The following scenarios give examples of using the <b>ascmd</b> command-line utility.</p>
    </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <h3 class="subHeading" xmlns="">Processing a Partition from a Third-Party Tool</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">A database administrator must process partitions and dimensions as part of a nightly extract, transform, and load (ETL) process. The ETL tool is not a SQL Server tool and the database administrator cannot use SQL Server Agent’s built-in support of XMLA scripts or run a SQL Server Integration Services package. The database administrator wants an automated solution that uses the third-party tool. The solution is a command-line utility to run an XMLA script. The utility is then called from the third-party tool. The database administrator downloads and compiles the <b>ascmd</b> command-line utility sample. After compilation, the database administrator can use the <b>ascmd</b> command-line utility to execute XMLA scripts that process partitions and dimensions. </p>
        </content></div>
      <h3 class="subHeading" xmlns="">Backing Up an OLAP Database from a Third-Party Tool</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">Another database administrator at the same company is required to automate the back-up of an Analysis Services database. Again, because the scheduling software that the company is using is not a SQL Server tool, the task has to be run from the command line. The database administrator generates the appropriate XMLA script (using SQL Server Management Studio). Then, the third-party scheduling software uses the <b>ascmd</b> command-line utility to run the XMLA script to backup the OLAP database. </p>
        </content></div>
      <h3 class="subHeading" xmlns="">Using XMLA During an Installation</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">A developer for an independent software vendor is required to integrate the execution of an XMLA script directly into the installation of the firm's product. The developer must run an XMLA script and retrieve status (and trace events) to know that the Analysis Services database was created correctly. The developer can do this by using the <b>ascmd</b> command-line utility.</p>
        </content></div>
    </sections></div><h1 class="heading">Languages</h1><div id="sectionSection1" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <ul xmlns=""><li>
          C#, the language that <b>ascmd</b> itself is coded in.<br></br>
        </li><li>
          Batch file commands, which start the <b>ascmd</b> command-line utility.<br></br>
        </li></ul>
    </content></div><h1 class="heading">Prerequisites</h1><div id="sectionSection2" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">To effectively use the <b>ascmd</b> command-line utility, you should have some or all of the following software installed:</p>
      <dl xmlns=""><dt>
          Microsoft SQL Server Analysis Services</dt><dd>
          <p>An instance of Analysis Services must be installed and running, because the <b>ascmd</b> command-line utility<b> </b>is used to connect to an instance of Analysis Services and execute MDX queries, XMLA scripts, and DMX statements.</p>
        </dd></dl><dl xmlns=""><dt>
          SQL Server Management Studio and Business Intelligence Development Studio</dt><dd>
          <p>These two work environments provide supporting infrastructure for you to complete any task related to Analysis Services. For any given task, you can approach implementation through the user interface or programmatically.</p>
        </dd></dl><dl xmlns=""><dt>Analysis Management Objects (AMO) </dt><dd>
          <p>AMO is required to execute the <b>ascmd</b> command-line utility on a computer that does not have Analysis Services installed. AMO can be installed from the SQL Server Feature Pack, which can be downloaded from the <a href="http://go.microsoft.com/fwlink/?linkid=11899" alt=""><linkText xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">Microsoft Download Center</linkText></a> at http://www.microsoft.com/downloads.</p>
        </dd></dl><dl xmlns=""><dt>
          .NET Framework 2.0 </dt><dd>
          <p>The .NET Framework 2.0 is required for the <b>ascmd</b> command-line utility to run. It can be downloaded from the <a href="http://go.microsoft.com/fwlink/?linkid=11899" alt=""><linkText xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">Microsoft Download Center</linkText></a> at http://www.microsoft.com/downloads.</p>
        </dd></dl><dl xmlns=""><dt>Microsoft Visual Studio 2005 or .NET Framework SDK 2.0</dt><dd>
          <p>We recommended that you use Visual Studio 2005 when you are building or customizing the <b>ascmd</b> sample application. If you do not have Visual Studio 2005 available, use the .NET Framework SDK 2.0. The .NET Framework SDK includes the MSBuild.exe (see the “Compiling the Sample” installation later in this document).</p>
        </dd></dl><dl xmlns=""><dt>The Adventure Works DW database included with SQL Server</dt><dd>
          <p>The database samples are useful for experimenting with the <b>ascmd</b> command-line utility. For more information, see <b>Running Setup to Install AdventureWorks Sample Databases and Samples</b> in SQL Server Books Online.</p>
          <p>An updated version of AdventureWorks database is also available for download on the <a href="http://go.microsoft.com/fwlink/?linkid=62796" alt=""><linkText xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">SQL Server Developer Center</linkText></a> Web page.</p>
          <p>An updated version of the SQL Server Database Engine samples is also available for download on the <a href="http://go.microsoft.com/fwlink/?linkid=62796" alt=""><linkText xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">SQL Server Developer Center</linkText></a> Web page. </p>
        </dd></dl>
    </content></div><h1 class="heading">Arguments</h1><div id="sectionSection3" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">The following arguments are supported at the command line for <b>ascmd</b>.</p>
      <dl xmlns=""><dt>
          <b>–U</b> <i>login_id</i> </dt><dd>
          <p>Is the user login ID, which is case-insensitive. </p>
          <div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
            the use of <i>login_id</i> is different for <b>sqlcmd</b> and <b>ascmd</b>. In <b>sqlcmd</b>, <i>login_id</i> represents a SQL Server login; for <b>ascmd</b> it represents a Windows login.<p></p>
          </td></tr></table><p></p></div>
          <p>For TCP/IP access, Analysis Services only supports trusted connections. If the <b>–U</b> parameter is specified (together with the matching password using the <b>–P</b> parameter), the <b>ascmd</b> command-line utility logs on to the Windows operating system using the specified account and then impersonates the account when executing the XMLA script, MDX query, or DMX statement. The login ID must be in the form <i>&lt;domain&gt;</i>\<i>&lt;username&gt;,</i> and the domain must be specified. If <b>–U</b> is not specified, authentication is based on the Windows account of the user who is running the <b>ascmd</b> command-line utility.</p>
          <p>If an http (or https) connection is specified by the <b>–S</b> parameter, the <b>ascmd</b> command-line utility does not log on to the Windows operating system. Instead, the <b>–U</b> and <b>–P</b> parameters (if present) are included as part of the connect string to the Internet Information Services (IIS) server. Depending on how IIS is configured, the <b>–U</b> and <b>–P</b> parameters can be used for basic authentication. For more information about the “UID” connect string parameter, see <b>AdomdConnection</b> Class in SQL Server Books Online.</p>
        </dd></dl><dl xmlns=""><dt>
          <b>–P</b> <i>password</i> </dt><dd>
          <p>Is a user-specified matching password to the <b>–U</b> parameter. If the <b>–U</b> parameter is specified and the <b>–P</b> parameter is not specified, the password is assumed to be blank (an empty, zero-length string). If the <b>–P</b> parameter is specified and the <b>–U</b> parameter is not, the <b>–P</b> parameter is ignored.</p>
          <div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Security Note: </th></tr><tr><td>
            Do not use a blank password. Use a strong password. For more information, see <b>Strong Passwords</b> in SQL Server Books Online.<p></p>
            The <b>–P</b> parameter password is stored as clear text in the script, query, or statement file; it will be visible to anyone who can see the computer monitor or read the file itself. If you use this feature, put ACLs on the files or use other security techniques to make sure that only trusted users can read the files.<p></p>
          </td></tr></table><p></p></div>
        </dd></dl><dl xmlns=""><dt>
          <b>–S</b> <i>server\instance</i> or <b>–S</b> <i>http[s]://server[:port]/virtualdirectory/msmdpump.dll</i></dt><dd>
          <p>Specifies the Analysis Services instance to which the <b>ascmd</b> command-line utility will connect and execute. If the <b>–P</b> parameter is not specified, the <b>ascmd</b> command-line utility connects to the default instance of Analysis Services on the local computer that is running TCP (connecting to localhost) and executes the XMLA script, MDX query, or DMX statement. </p>
        </dd></dl><dl xmlns=""><dt>
          <b>–d</b> <i>database</i></dt><dd>
          <p>Specifies the database against which an MDX query or DMX statement will execute. The <b>–d</b> parameter is ignored when the <b>ascmd</b> command-line utility executes an XMLA script, because XMLA scripts have the database name embedded within the XMLA script.</p>
        </dd></dl><dl xmlns=""><dt>
          <b>–t</b> <i>query-timeout</i></dt><dd>
          <p>Specifies the number of seconds before the execution of an XMLA script, MDX query, or DMX statement times out. The <b>ascmd</b> command-line utility adds the <b>TIMEOUT =</b><b> </b><i>&lt;query-timeout&gt;</i> clause to the connect string.</p>
        </dd></dl><dl xmlns=""><dt>
          <b>–tc</b> <i>connect-timeout</i></dt><dd>
          <p>Specifies the number of seconds before the <b>ascmd</b> connection to the Analysis Services instance times out. The <b>ascmd</b> command-line utility adds the <b>CONNECT TIMEOUT = </b><i>&lt;connect-timeout&gt;</i> clause to the connect string.</p>
        </dd></dl><dl xmlns=""><dt>
          <b>–i</b> <i>input-file</i></dt><dd>
          <p>Identifies the file that contains the XMLA script, MDX query, or DMX statement. You must specify a value for either the <b>–i</b> or the <b>–Q</b> parameter when you use the <b>ascmd</b> command-line utility. If you specify no <b>–i</b> or<b>–Q</b> parameter, or specify both of these parameters, an error is generated. </p>
          <div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
            Unlike the <b>sqlcmd</b> command-line utility (which can handle multiple input files), the <b>ascmd</b> command-line utility can only process one input file at a time. If you have more than one input file, each one must be called and executed separately.<p></p>
          </td></tr></table><p></p></div>
          <p>The input file specified with either the <b>–i</b> or the <b>–Q</b> parameter must be a valid XML structure and special characters must be HTML-encoded. For example, when you use an ampersand (&amp;) in your text, it must be encoded as <code>&amp;amp;</code>. So [Product].&amp;1922] will be encoded as [Product].&amp;amp;[1922]. Likewise, a less-than sign (&lt;) must be encoded as <code>&amp;lt;</code>, a greater-than sign (&gt;) as <code>&amp;gt;</code>, and double quotation marks (") as <code>&amp;quot;</code>. This is important for MDX queries and DMX statements because the syntax of member keys uses the ampersand character (&amp;). </p>
          <div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
            If the input text does not look like it is an XMLA script, that is, it does not start with a valid XMLA command such as &lt;Statement&gt; or &lt;Create&gt; (see the full list later in this document), then the <b>ascmd</b> command-line utility assumes that the text is a &lt;Statement&gt; and HTML encodes the text for you and wraps it in a &lt;Statement&gt; … &lt;/Statement&gt; XML element tag. This is done as a convenience so that executing MDX queries and DMX statements are easier. If you want to use &lt;Statement&gt; elements and write the HTML text yourself, you can do that. Any valid XMLA command is accepted by the <b>ascmd</b> command-line utility.<p></p>
          </td></tr></table><p></p></div>
          <p>An input file can contain multiple batches, separated by GO commands. Each batch within an input file can contain an XMLA script, an MDX query, or a DMX statement. Each GO command must appear on a single line. When a GO command is found, the system sends the input preceding the GO command to the server. An implied GO command is at the end of the input stream. The generated output file is formatted by wrapping the returned XML streams with a &lt;multiple-batches&gt; element. See Scenario 11 for an example of an input file that contains multiple batches.</p>
          <p>Each batch executes and succeeds or fails in its own right. The return status of each batch is recorded in the output file, which you must parse to determine the success or failure of each batch.</p>
        </dd></dl><dl xmlns=""><dt>
          <b>–o</b> <i>output-file | NUL | NUL:filename</i></dt><dd>
          <p>Identifies the file that receives (in XML) the results of the XMLA script or the cellset return by the MDX query or DMX statement. If the specified file already exists, the existing file is automatically overwritten. File names that contain spaces must be enclosed in quotation marks (""). If the file name is not valid, an error message is generated, and the <b>ascmd</b> command-line utility exits. </p>
          <p>The <b>ascmd</b> command-line utility does not support concurrent writing of multiple <b>ascmd</b> processes to the same file; if this is tried, the file output will be corrupted or incorrect.</p>
          <p>If the specified output file is <i>NUL</i> or <i>NUL:filename</i>, the execution results are discarded unless the <b>–T</b> parameter is used to specify a trace file, in which case the execution results are stored in the trace file. Specifying a <i>NUL</i> output file and with the <b>–T</b> parameter is most useful when specifying a <i>Duration</i> trace level with the <b>–Tl</b> parameter. </p>
          <p>For example, you could create a series of MDX queries and execute them with the <b>ascmd</b> command-line utility, ignore the output (which might be very large), record the query durations into a trace file, and then load the query duration values in the trace file into a database. This lets you evaluate performance variations over time. Alternatively, you could use the <i>Duration-result</i> trace level with the <b>–Tl</b> parameter to include both the duration and the execution result in the trace file.</p>
          <div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
            The <b>ascmd</b> command-line utility supports international encoding. Input and output files use UTF-8 encoding with byte-order markers enabled. If your text editor does not support UTF-8 and you have international characters in your MDX query, in your XMLA script, or in your DMX statement, you can use Notepad to convert the input file into UTF-8 format. To convert the input file to UTF-8, open the file in Notepad, on the <b>File</b> menu select <b>Save As</b>, and in the <b>Encoding</b> box, select <b>UTF-8</b>. Then you can use the file together with the <b>–i</b> parameter. Output and trace files (<b>–o</b> and <b>–T</b>) are always written with UTF-8 encoding and byte-order markers to ensure that Unicode characters are preserved.<p></p>
          </td></tr></table><p></p></div>
        </dd></dl><dl xmlns=""><dt>
          <b>–T</b> <i>trace-file</i></dt><dd>
          <p>Identifies a file that receives Analysis Services trace events from the <b>ascmd</b> command-line utility executing the XMLA script, MDX query, or DMX statement. If the file already exists, it is automatically overwritten (except for the trace files that are created by using the <b>–Tl</b> <i>Duration</i> and <b>–Tl</b> <i>Duration-result</i> parameter settings). File names that contain spaces must be enclosed in quotation marks (""). If the file name is not valid, an error message is generated, and the <b>ascmd</b> command-line utility exits. </p>
          <p>The <b>ascmd</b> command-line utility does not support concurrent writing of multiple <b>ascmd</b> processes to the same file; if this is tried, the file output will be corrupted or incorrect. If the <b>–T</b> parameter is not specified, the trace output is not captured and the <b>–Tf</b>, <b>–Tl</b>, <b>Td</b> and <b>–Tt</b> parameters are ignored.</p>
          <div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
            the <b>–T</b> parameter is unavailable when you are using http or https access. You must use an ordinary client/server connection, by specifying the <b>–S</b> parameter.<p></p>
          </td></tr></table><p></p></div>
        </dd></dl><dl xmlns=""><dt>
          <b>–xc</b> <i>extended-connect-string</i></dt><dd>
          <p>Specifies an extended connect string that is inserted directly into the connect string, without any value checking. The string should not contain any leading or trailing semi-colons (;). For example, the following extended connect string changes the network packet size used between the server and the <b>ascmd</b> process from 4096 to 16384 and also requests that the client locale be set to en-US (US English):</p>
          <p>
            <code>-xc "Packet Size=16384;LocaleIdentifier=1033"</code>
          </p>
          <p>The default for the <b>ascmd</b> command-line utility is not to add any extended connect string information. Although many of the options of the <b>ascmd</b> command-line utility can be implemented as extended connect string setting (for example by setting <b>Database=</b><i>&lt;database name&gt;</i> directly), we recommend that you use the standard <b>ascmd</b> options when you can and only use extended connect string settings when you have no other mechanism available.</p>
        </dd></dl><dl xmlns=""><dt>
          <b>–Tf</b> <i>text | csv</i></dt><dd>
          <p>Specifies the file format for the <b>–T</b> parameter (if this parameter is specified). The default value is <i>csv</i>. The available options are as follows:</p>
          <ul><li>
              For text, the file is written in a text format. Examples of the format are as follows: <br></br>
              &lt;current time&gt; &lt;event-class&gt;.&lt;event-subclass&gt;, [name=value]<br></br>
            </li><li>
              For <i>csv</i>, the file is written in comma-separated format. The default column delimiter is <b>|</b> (pipe, or vertical bar); use the <b>–Td</b> parameter to change the default delimiter for a csv file. The first line in the file specifies column headings for the values.<br></br>
            </li></ul>
        </dd></dl><dl xmlns=""><dt>
          <b>–Td</b> <i>delim-char</i></dt><dd>
          <p>Specifies a single character as the trace file delimiter when specifying csv as the format for the trace file that use the <b>–Tf</b> parameter. Default is <b>|</b> (pipe, or vertical bar).</p>
        </dd></dl><dl xmlns=""><dt>
          <b>–Tt</b> <i>trace-timeout</i></dt><dd>
          <p>Specifies the number of seconds the Analysis Services engine waits before ending the trace (if you specify the <b>–T</b> parameter). The trace is considered finished if no trace messages have been recorded during the specified time period. The default trace time-out value is 5 seconds. </p>
        </dd></dl><dl xmlns=""><dt>
          <b>–Tl</b> <i>trace-level</i></dt><dd>
          <p>Specifies what data is collected and recorded in the trace file. This parameter has the following five possible values:</p>
          <ul><li>
              
                <i>High</i> – records all trace events - this is the default setting.<br></br>
            </li><li>
              
                <i>Medium</i> – records all trace events except the ProgressReportCurrent and Notification events.<br></br>
            </li><li>
              
                <i>Low</i> – records only those trace events that contain "End" or "Error" in the event.<br></br>
            </li><li>
              
                <i>Duration</i> – records no trace events, but instead determines the duration of the execution of the script, query, or statement by the <b>ascmd</b> process. Writes a single entry into the trace file that includes the current time, duration, execution text, database, and server name.<br></br>
            </li><li>
              
                <i>Duration-result</i> – records the same information as the Duration setting and also records the result of the execution in the last column of the trace file.<br></br>
            </li></ul>
          <div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
            The trace files generated with the <i>Duration</i> and <i>Duration-result</i> settings are not overwritten with each execution (as is the case with trace files generated with the <i>High</i>, <i>Medium</i> and <i>Low</i> settings). Instead, with the <i>Duration</i> and <i>Duration-result</i> settings, if an existing trace file exists, it is opened and new values are appended to the end of the file. If the trace file does not already exist, it is created.<p></p>
          </td></tr></table><p></p></div>
        </dd></dl><dl xmlns=""><dt>
          <b>–Q</b> <i>"cmdline query or script"</i></dt><dd>
          <p>Specifies the actual script, query, or statement directly on the command line instead of in a file.</p>
          <div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
            The <b>sqlcmd</b> command-line utility supports an additional ways to specify the input query (using the <b>–q</b> parameter). Unfortunately, because that option reads from sysinput, you cannot write it unless you add more language constructs. For example, <b>sqlcmd</b> uses “go” and “exit” to control sysinput commands. This additional way to specify query input is not supported by the <b>ascmd</b> command-line utility.<p></p>
          </td></tr></table><p></p></div>
        </dd></dl><dl xmlns=""><dt>
          <b>–v</b> var=value...</dt><dd>
          <p>Specifies additional scripting variables. Each variable is a var = value pair. If the value contains embedded spaces or control characters, it must be enclosed in double-quotes (").For example, </p>
          <p>
            <code>-v maxparallel=4 option= "degree of freedom"</code>
          </p>
          <p>You can specify zero, one, or more than one var = value pairs. </p>
        </dd></dl><dl xmlns=""><dt>
          <b>–?</b> or <b>/?</b></dt><dd>
          <p>Displays the syntax summary of the <b>ascmd</b> command-line utility options.</p>
        </dd></dl>
    </content></div><h1 class="heading">Key Encryption and Compiling the Sample</h1><div id="sectionSection4" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">
        	
	<p>If you have not already created a strong name key file, generate the key file using the following instructions.</p>
	<h4 class="procedureHeading">
	
	To generate a strong name key file
	</h4>
	<div id="procedureSectionEDBDBHA" class="section">
	<ol>
	<li>Open a Microsoft Visual Studio 2005 command prompt. Click <b>Start</b>, point to <b>All Programs</b>, point to <b>Microsoft .NET Framework SDK 2.0</b>, and then click <b>SDK Command Prompt</b>.<p>-- or --</p>
	<p>Open a Microsoft .NET Framework command prompt. Click <b>Start</b>, point to <b>All Programs</b>, point to <b>Microsoft .NET Framework SDK 2.0</b>, and then click <b>SDK Command Prompt</b>.</p>
	</li>
	<li>Use the change directory command (CD) to change the current directory of the command prompt window to the folder where the samples are installed.<div class="alert">
	<table width="100%" cellspacing="0" cellpadding="0">
	<tr>
	<th align="left">
	Note:</th>
	</tr>
	<tr>
	<td>To determine the folder where samples are located, click the <b>Start</b> button, point to <b>All Programs</b>, point to <b>Microsoft SQL Server</b>, point to <b>Documentation and Tutorials</b>, and then click <b>Samples Directory</b>. If the default installation location was used, the samples are located in &lt;system_drive&gt;:\Program Files\Microsoft SQL Server\100\Samples.
	</td>
	</tr>
	</table>
	</div>
	</li>
	<li>At the command prompt, run the following command to generate the key file:<p>
	<code>sn -k SampleKey.snk</code>
	</p>
	<div class="alert">
	<table width="100%" cellspacing="0" cellpadding="0">
	<tr>
	<th align="left">
	Important:</th>
	</tr>
	<tr>
	<td>For more information about the strong-name key pair, see "Security Briefs: Strong Names and Security in the .NET Framework" in the .NET Development Center on MSDN.</td>
	</tr>
	</table>
	</div>
	</li>
	</ol>
	</div>

      </p>
      <p xmlns="">Compilation of the sample can be done by using one of the following two approaches. </p>
      <ul xmlns=""><li>
          Using Visual Studio 2005 <b>–</b> compile the sample by using the provided Visual Studio solution in the <i>&lt;install_path&gt;</i>\Samples\Analysis Services\Administrator\ascmd\cs folder. <br></br>
        </li><li>
          Using MSBuild, which is included in the.NET Framework SDK 2.0, compile the sample by running the following commands at the command prompt:<br></br>
          <div class="code"><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>cd Analysis Services\Administrator\ascmd\CS\ascmd
msbuild ascmd.csproj /nologo /v:quiet /p:Configuration=Debug;Platform=<i>&lt;platform&gt;</i></pre></td></tr></table></span></div>
        </li></ul>
      <div class="alert" xmlns=""><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
        Microsoft Visual Studio is fully supported on x86 and x64-based computers, but is not supported on Itanium-based computers. Once the <b>ascmd</b> command-line utility is compiled, the <b>ascmd</b> command-line utility can be executed on any x86, x-64, or Itanium-based computer.<p></p>
      </td></tr></table><p></p></div>
      <p xmlns="">In the previous code, the <i>&lt;platform&gt;</i> parameter value can be <i>x86</i> for 32-bit computers, <i>x64</i> for x64-based computers, or <i>Itanium</i> for IA-64-based computers. It is a best practice to compile the appropriate version of the <b>ascmd</b> command-line utility because performance might be decreased when executing 32-bit code on a 64-bit computer. </p>
      <div class="alert" xmlns=""><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
        If you are compiling the <b>ascmd</b> command-line utility on a computer whose architecture is different from the target computer (for example compiling the <b>ascmd</b> command-line utility on a 32-bit computer using either the <i>x64</i> or <i>Itanium</i> parameter value, then you will receive three warning messages that indicate that three separate system DLLs are not available ("…targets a different processor"). This is typical and expected. After you compile the <b>ascmd</b> command-line utility, copy the compiled executable to your target server and execute it from the target server (where the appropriate DLLs are available).<p></p>
      </td></tr></table><p></p></div>
    </content></div><h1 class="heading">Using Scripting and Environment Variables</h1><div id="sectionSection5" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">The <b>ascmd</b> command-line utility supports system-reserved and user-defined scripting variables that you can use in XMLA scripts, MDX queries, and DMS statements. Values for these variables can be populated by specifying values for environment variables or by specifying values for command-line parameters.</p>
      <p xmlns="">The following rules apply to user-defined scripting variables and environment variables: </p>
      <ul xmlns=""><li>
          A variable can contain any number of lowercase characters, uppercase characters, digits, dashes (-), or underscores (_). <br></br>
        </li><li>
          A variable cannot contain embedded characters or control characters, for example CR, LF, TAB. <br></br>
        </li></ul>
    </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <h3 class="subHeading" xmlns="">System-Reserved Scripting Variables</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">System-reserved scripting variables are scripting variables that are defined by the <b>ascmd</b> command-line utility to hold the values associated with each command-line parameter. In some cases, environment variables can also be used to hold the values for these system-reserved scripting variables. For system-reserved scripting variables that can be populated or derived from both environment variables and command-line parameters, the value specified for the command-line parameter (if it is specified) overwrites any specified environment variable value. </p>
          <p xmlns="">The following table describes the system-reserved scripting variables, the associated command-line parameters, and where applicable, the associated environment variables.</p>
          <div class="alert" xmlns=""><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
            There are three system-reserved scripting variables that can only be set by using a command-line parameter (the <b>–i</b>, <b>–o</b>, and <b>–T</b> parameters). There is no corresponding ASCMD environment variable that you can use to populate the system-reserved scripting variable that corresponds to those three command-line parameters.<p></p>
          </td></tr></table><p></p></div>
          <h3 class="subHeading" xmlns=""></h3><table width="100%" cellspacing="0" cellpadding="0" border="1" style="background-color: #CCCCCC;" xmlns=""><tr>
                <th>
                  System-Reserved Scripting Variable
                </th>
                <th>
                  Parameter
                </th>
                <th>
                  Environment Variable (if any)
                </th>
              </tr><tr>
              <td>
                <p>
                  <b>ASCMDUSER</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–U</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDUSER</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDDOMAIN</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–U</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDUSER</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDPASSWORD</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–P</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDPASSWORD</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDSERVER</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–S</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDSERVER</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDINSTANCE</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–S</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDSERVER</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDHTTPCONNECTION</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–S</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDSERVER</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDDBNAME</b>
                </p>
              </td>
              <td>
                <p>–<b>d</b></p>
              </td>
              <td>
                <p>
                  <b>ASCMDDBNAME</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDINPUTFILE</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–i</b>
                </p>
              </td>
              <td>
                <p> </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDOUTPUTFILE</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–o</b>
                </p>
              </td>
              <td>
                <p> </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDQUERYTIMEOUT</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–t</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDQUERYTIMEOUT</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDCONNECTTIMEOUT</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–tc</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDCONNECTTIMEOUT</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDTRACEFILE</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–T</b>
                </p>
              </td>
              <td>
                <p> </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDTRACEFORMAT</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–Tf</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDTRACEFORMAT</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMETRACEDELIM</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–Td</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDTRACEDELIM</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDTRACELEVEL</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–Tl</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDTRACELEVEL</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDTRACETIMEOUT</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–Tt</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDTRACETIMEOUT</b>
                </p>
              </td>
            </tr><tr>
              <td>
                <p>
                  <b>ASCMDEXTENDEDCONNECTION</b>
                </p>
              </td>
              <td>
                <p>
                  <b>–xc</b>
                </p>
              </td>
              <td>
                <p>
                  <b>ASCMDEXTENDEDCONNECTSTRING</b>
                </p>
              </td>
            </tr></table>
          <p xmlns="">Notice that in some cases in the previous table, multiple system-reserved scripting variables are derived from a single parameter or environment variable. In the following example, three system-reserved scripting variables are derived from the ASCMDSERVER environment variable setting. </p>
          <ul xmlns=""><li>
              C:\&gt;SET ASCMDSERVER=http://myserver/my_virtual_dir/msmdpump.dll<br></br>
            </li></ul>
          <p xmlns="">The previous SET statement specifying a value for the ASCMDSERVER environment variable sets the following values for the following three system-reserved scripting variables:</p>
          <ul xmlns=""><li>
              ASCMDSERVER="http://myserver/my_virtual_dir/msmdpump.dll"<br></br>
            </li><li>
              ASCMDINSTANCE=""<br></br>
            </li><li>
              ASCMDHTTPCONNECTION="true"<br></br>
            </li></ul>
          <p xmlns="">In a following example, the same three system-reserved scripting variables are populated with different values by using a different SET statement: </p>
          <ul xmlns=""><li>
              C:\&gt;SET ASCMDSERVER=myserver\myinstance<br></br>
            </li></ul>
          <p xmlns="">The previous SET statement specifying a value for the ASCMDSERVER environment variable sets values for the following three system-reserved scripting variables:</p>
          <ul xmlns=""><li>
              ASCMDSERVER="myserver"<br></br>
            </li><li>
              ASCMDINSTANCE="myinstance"<br></br>
            </li><li>
              ASCMDHTTPCONNECTION="false"<br></br>
            </li></ul>
        </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <h4 class="subHeading" xmlns="">Using System-Reserved Scripting Variables at the Command Prompt</h4><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">If an environment variable exists that matches a system-reserved scripting variable (matching is case-insensitive), the environment variable’s value is used as the default value for the system-reserved scripting variable, and for the associated command-line parameter. For example, you can use the following SET statement was executed to set the ASCMDDBNAME environment variable: </p>
              <ul xmlns=""><li>
                  C:\&gt;SET ASCMDDBNAME="Adventure Works DW"<br></br>
                </li></ul>
              <p xmlns="">In this case, “Adventure Works DW” will be used as the default database (<b>–d</b> parameter) when you execute the <b>ascmd</b> command-line utility (unless you specify a different value at the command-line). </p>
            </content></div>
          <h4 class="subHeading" xmlns="">Using System-Reserved Scripting Variables in Scripts, Queries, or Statements</h4><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">System-defined scripting variables can also be used in an XMLA script, an MDX query, or a DMX statement. The following examples illustrate sample command-line invocations of the <b>ascmd</b> command-line utility that use scripting variables. More examples appear later in this document to illustrate usage scenarios.</p>
              <ul xmlns=""><li>
                  C:\&gt;ascmd -S <i>&lt;server name&gt;</i> -i process.xmla -v cube=<i>&lt;CubeID&gt;</i><br></br>
                </li></ul>
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">process.xmla (simplified)</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Batch&gt;
    &lt;Parallel&gt;
         &lt;Process&gt;
             &lt;Object&gt;
                  &lt;DatabaseID&gt;$(ASCMDDBNAME)&lt;/DatabaseID&gt;
                  &lt;CubeID&gt;($CUBE)&lt;/CubeID&gt;
            . . .
         &lt;/Process&gt;
    &lt;/Parallel&gt;
&lt;/Batch&gt;</pre></td></tr></table></span></div>
                    </content></div>
                </sections></div>
            </sections></div>
        </sections></div>
      <h3 class="subHeading" xmlns="">User-Defined Scripting Variables</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">A user-defined scripting variable is a scripting variable that is defined by using the <b>–v</b> parameter at the command line, or is defined as an environment variable. When the <b>ascmd</b> command-line utility encounters a variable in an XMLA script, an MDX query, or a DMX statement, and the variable has not been populated using the <b>–v</b> parameter, the utility checks for an environment variable of the same name and uses that variable's value. If the <b>ascmd</b> command-line utility does not find a matching environment variable, the scripting variable is eliminated by replacing it with a blank string ("").</p>
          <p xmlns="">The following rules apply to user-defined scripting variables defined by using the <b>–v</b> parameter at the command line: </p>
          <ul xmlns=""><li>
              Leading and trailing spaces are removed from the “value” section of a variable.<br></br>
            </li><li>
              The variable cannot start with the string “ascmd”.<br></br>
            </li></ul>
        </content></div>
    </sections></div><h1 class="heading">Using MDX, XMLA, and DMX in Input Files</h1><div id="sectionSection6" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">The <b>ascmd</b> command-line utility supports the execution of MDX queries, XMLA scripts, and DMX statements within input files. The input script that you pass to the<b> ascmd</b> command-line utility is actually an XMLA Command element. </p>
      <p xmlns="">Command elements are as follows: </p>
      <ul xmlns=""><li>
          Alter<br></br>
        </li><li>
          Backup<br></br>
        </li><li>
          Batch<br></br>
        </li><li>
          BeginTransaction<br></br>
        </li><li>
          Cancel<br></br>
        </li><li>
          ClearCache<br></br>
        </li><li>
          CommitTransaction<br></br>
        </li><li>
          Create<br></br>
        </li><li>
          Delete<br></br>
        </li><li>
          DesignAggregations<br></br>
        </li><li>
          Drop<br></br>
        </li><li>
          Insert<br></br>
        </li><li>
          Lock<br></br>
        </li><li>
          MergePartitions<br></br>
        </li><li>
          NotifyTableChange<br></br>
        </li><li>
          Process<br></br>
        </li><li>
          Restore<br></br>
        </li><li>
          RollbackTransaction<br></br>
        </li><li>
          Statement (used to execute MDX queries and DMX statements)<br></br>
        </li><li>
          Subscribe<br></br>
        </li><li>
          Synchronize<br></br>
        </li><li>
          Unlock<br></br>
        </li><li>
          Update<br></br>
        </li><li>
          UpdateCells<br></br>
        </li></ul>
      <p xmlns="">To perform commands on more than one object at a time, use the &lt;Batch&gt; command. To execute for MDX queries and DMX statements, use the &lt;Statement&gt; command. For more information, see <b>Command Element (XMLA)</b> in SQL Server Books Online. The following examples show how to structure MDX queries, DMX statements, and XMLA scripts.</p>
      <div class="alert" xmlns=""><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Important: </th></tr><tr><td>
        Like all XML structures, commands are case sensitive. Therefore, for example, you must enclose all MDX queries in &lt;Statement&gt; …. &lt;/Statement&gt; tags and the command must be “Statement”, it cannot be “statement” or “STATEMENT”.<p></p>
      </td></tr></table><p></p></div>
      <p xmlns="">In addition to XMLA Commands, the <b>ascmd</b> command-line utility can also be used to execute custom XMLA requests to execute virtually any request that can be expressed in XMLA. For example, the <b>ascmd</b> command-line utility can be used to issue either of the following XMLA requests:</p>
      <ul xmlns=""><li>
          Discover XMLA requests to query Analysis Services metadata. This metadata includes information about the following: <br></br>
          <ul><li>
              Objects stored in an Analysis Services database, such as the cubes defined on the server; and<br></br>
            </li><li>
              Resources being used, such as the connections that are open on the server.<br></br>
            </li></ul>
        </li><li>
          Execute requests that perform Commands but modify them by specifying a Property List and a Parameters List. An example of this type of request is provided later in this document <b>–</b> see the Execute Example.<br></br>
        </li></ul>
      <p xmlns="">If the input text is not formatted as an XMLA Command, a Discover request, or an Execute request, then the <b>ascmd</b> command-line utility assumes that the input text is a MDX query or DMX statement. In this case, the <b>ascmd</b> command-line utility HTML encodes the text and wraps a &lt;Statement&gt; … &lt;/Statement&gt; element around it and processes it as an XMLA Command. This allows you to easily enter a MDX query or DMX statement. See Scenario 1 "Querying an Analysis Services Cube" later in this document for an example of how to use this capability.</p>
    </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <h3 class="subHeading" xmlns="">MDX Example:</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Statement&gt;
SELECT NON EMPTY
         [Employees].Members ON ROWS,
         [Measures].[Internet Gross Profit] ON COLUMNS 
FROM [Adventure Works]
&lt;/Statement&gt;</pre></td></tr></table></span></div>
          <p xmlns="">This example uses an MDX query in an XMLA Statement to return the Internet Gross Profit measure for each member of the Employees attribute hierarchy that is not empty from the Adventure Works cube.</p>
        </content></div>
      <h3 class="subHeading" xmlns="">DMX Example:</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Statement&gt;
ALTER MINING STRUCTURE [Bike Buyer]
ADD MINING MODEL [Decision Tree]
(
    [Customer Key],
    [Age],
    [Bike Buyer] PREDICT,
    [Commute Distance],
    [Education],
    [Gender],
    [House Owner Flag],
    [Marital Status],
    [Number Cars Owned],
    [Number Children At Home],
    [Occupation],
    [Region],
    [Total Children],
    [Yearly Income]
) USING Microsoft_Decision_Trees
WITH DRILLTHROUGH
&lt;/Statement&gt;</pre></td></tr></table></span></div>
          <p xmlns="">This example uses a DMX query in an XMLA Statement change the [Bike Buyer] mining structure by adding a new mining model.</p>
        </content></div>
      <h3 class="subHeading" xmlns="">XMLA Example:</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Batch xmlns="http://schemas.microsoft.com/analysisservices/2003/engine"&gt;
   &lt;Parallel&gt;
      &lt;Process xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
         &lt;Object&gt;
            &lt;DatabaseID&gt;Adventure Works DW&lt;/DatabaseID&gt;
            &lt;CubeID&gt;Adventure Works DW&lt;/CubeID&gt;
            &lt;MeasureGroupID&gt;Fact Internet Sales 1&lt;/MeasureGroupID&gt;
            &lt;PartitionID&gt;Internet_Sales_2001&lt;/PartitionID&gt;
         &lt;/Object&gt;
         &lt;Type&gt;ProcessFull&lt;/Type&gt;
         &lt;WriteBackTableCreation&gt;UseExisting&lt;/WriteBackTableCreation&gt;
      &lt;/Process&gt;
   &lt;/Parallel&gt;
&lt;/Batch&gt;</pre></td></tr></table></span></div>
          <p xmlns="">This example uses an XMLA Statement to fully process the Internet_Sales_2001 partition.</p>
        </content></div>
      <h3 class="subHeading" xmlns="">Discover Example:</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Discover xmlns="urn:schemas-microsoft-com:xml-analysis"&gt;
   &lt;RequestType&gt;MDSCHEMA_CUBES&lt;/RequestType&gt;
   &lt;Restrictions&gt;
      &lt;RestrictionList&gt;
         &lt;CATALOG_NAME&gt;Adventure Works DW&lt;/CATALOG_NAME&gt;
      &lt;/RestrictionList&gt;
   &lt;/Restrictions&gt;
   &lt;Properties&gt;
      &lt;PropertyList&gt;
         &lt;Catalog&gt;Adventure Works DW&lt;/Catalog&gt;
         &lt;Format&gt;Tabular&lt;/Format&gt;
      &lt;/PropertyList&gt;
   &lt;/Properties&gt;
&lt;/Discover&gt;</pre></td></tr></table></span></div>
          <p xmlns="">This example uses an XMLA Discover request to return what cubes are available in the Adventure Works DW database. Because Perspectives are returned to applications as if they were cubes, the returned data actually includes both cubes and perspectives.</p>
        </content></div>
      <h3 class="subHeading" xmlns="">Execute Example:</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Execute xmlns="urn:schemas-microsoft-com:xml-analysis"&gt;
   &lt;Command&gt;
      &lt;Statement&gt;
         SELECT [Measures].MEMBERS ON COLUMNS FROM [Adventure Works]
      &lt;/Statement&gt;
   &lt;/Command&gt;
   &lt;Properties&gt;
      &lt;PropertyList&gt;
         &lt;Catalog&gt;Adventure Works DW&lt;/Catalog&gt;
         &lt;Format&gt;Tabular&lt;/Format&gt;
         &lt;AxisFormat&gt;ClusterFormat&lt;/AxisFormat&gt;
      &lt;/PropertyList&gt;
   &lt;/Properties&gt;
&lt;/Execute&gt;</pre></td></tr></table></span></div>
          <p xmlns="">This example uses an MDX query in an XMLA Statement. Notice, however, that the Property List portion of the XMLA request specifies that the return format is Tabular instead of Multidimensional. The multidimensional format is the default for an XMLA Statement command. Because the return format is in tabular (rowset) format, the output file could be used by an application that understands xsd flattened rowsets rather than a cellset, and the flattened rowset could be more easily loaded into a SQL relational database because it is now formatted as a table.</p>
        </content></div>
    </sections></div><h1 class="heading">ASCMD Scenario Examples</h1><div id="sectionSection7" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">The following scenarios demonstrate uses of the <b>ascmd</b> command-line utility.</p>
    </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <h3 class="subHeading" xmlns="">Scenario 1: Querying an Analysis Services Cube</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">In this scenario, you create an input file that contains an MDX query (the query.mdx file) that contains user-defined scripting variable (cube) in the MDX query. You then call this input file from the <b>ascmd</b> command-line utility and specify a value for this variable at the command-line by using the <b>–v</b> parameter.</p>
        </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">query.mdx file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <p xmlns="">Format 1:</p>
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Statement&gt;
/* THIS IS AN MDX COMMENT */
SELECT [Measures].[Internet Sales Amount] ON COLUMNS
FROM $(cube)
WHERE [Customer].[Country].&amp;amp;[United States]
&lt;/Statement&gt;</pre></td></tr></table></span></div>
                      <p xmlns="">Format 2:</p>
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>/* THIS IS AN MDX COMMENT */
SELECT [Measures].[Internet Sales Amount] ON COLUMNS
FROM $(cube)
WHERE [Customer].[Country].&amp;[United States]</pre></td></tr></table></span></div>
                    </content></div>
                  <h5 class="subHeading" xmlns="">Command-line example:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <p xmlns="">
                        <b>C:\&gt;ascmd -S myserver -d "Adventure Works DW" -i query.mdx -o result.xml -v cube="[Adventure Works]"</b>
                      </p>
                      <p xmlns="">Notice that using Format 1, the key for the United States is handled by replacing the MDX "&amp;" (which indicates that it is the member key and not the name) with &amp;amp; (as required for HTML encoding) and that the &lt;Statement&gt; element is specified. Notice that using Format 2, neither the HTML encoding nor the &lt;Statement&gt; element is needed. This is because the input text does not start with a valid XMLA command and that the <b>ascmd</b> command-line utility therefore assumes that the input text is a Statement and automatically HTML encodes the input and wraps it in a &lt;Statement&gt; element before execution. </p>
                    </content></div>
                </sections></div>
            </sections></div>
        </sections></div>
      <h3 class="subHeading" xmlns="">Scenario 2: Backing Up a Database in an Untrusted Domain</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">In this scenario, you back up a database on a server in an untrusted domain by using the <b>ascmd</b> command-line utility. Because the database is in an untrusted domain, this scenario requires http access. In this scenario, the remote server (called "myserver") has both Internet Information Services (IIS) and Analysis Services running, and has an IIS virtual directory named "olapadmin", which is configured to use BASIC authentication. Additionally, the remote server has a local account called "olapadmin" with appropriate backup permissions. You specify the database name, access method, username, password, and backup file at the command line by using <b>ascmd</b> command-line parameters, and specify an XMLA input file (backup.xmla) that contains the scripting variables for the database and backup file. </p>
        </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">backup.xmla file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Backup xmlns="http://schemas.microsoft.com/analysisservices/2003/engine"&gt;
   &lt;Object&gt;
      &lt;DatabaseID&gt;$(ascmddbname)&lt;/DatabaseID&gt;
   &lt;/Object&gt;
   &lt;File&gt;$(backupfile).abf&lt;/File&gt;
&lt;/Backup&gt;</pre></td></tr></table></span></div>
                    </content></div>
                  <h5 class="subHeading" xmlns="">Command-line example:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <p xmlns="">
                        <b>C:\&gt;ascmd -S https://myserver/msolap90/msmdpump.dll -U myserver\olapadmin -P #1PWD -d "Adventure Works DW" -i backup.xmla -v backupfile="AdvWorks"</b>
                      </p>
                      <p xmlns="">Notice that in the command-line example, https is used so that the password is encrypted when it is sent over the network to the remote server.</p>
                    </content></div>
                </sections></div>
            </sections></div>
        </sections></div>
      <h3 class="subHeading" xmlns="">Scenario 3: Processing Multiple Partitions</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">In this scenario, you process multiple partitions using the <b>ascmd</b> command-line utility. You use scripting variables in the XMLA processing script (process.xmla) to specify the degree of parallelism, the database and cube names, and the process type. This XMLA script also demonstrates the use of comments in an XMLA script. When you call the process.xmla processing script from the <b>ascmd</b> command-line utility, you specify the server and database name, an output file for XMLA results, a trace file for trace events, the trace level, and the degree of parallelism within a batch bat (process.bat). The trace file will contain the same events and information as SQL Server Profiler would return if an administrator was monitoring the system during the processing.</p>
        </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">process.xmla file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Batch xmlns="http://schemas.microsoft.com/analysisservices/2003/engine"&gt;
   &lt;Parallel maxparallel="$(MAXPARALLEL)"&gt;
   &lt;!-- SEE ABOVE FOR HOW MANY PARITIONS PROCESSED IN PARALLEL --&gt;
      &lt;Process xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
         &lt;Object&gt;
            &lt;DatabaseID&gt;$(ASCMDDBNAME)&lt;/DatabaseID&gt;
            &lt;CubeID&gt;$(ASCMDDBNAME)&lt;/CubeID&gt;
            &lt;!-- Just so happens CubeID=DatabaseID=Database name :-) --&gt;
            &lt;MeasureGroupID&gt;Fact Internet Sales 1&lt;/MeasureGroupID&gt;
            &lt;PartitionID&gt;Internet_Sales_2001&lt;/PartitionID&gt;
         &lt;/Object&gt;
         &lt;Type&gt;$(PROCESSTYPE)&lt;/Type&gt;
         &lt;WriteBackTableCreation&gt;UseExisting&lt;/WriteBackTableCreation&gt;
      &lt;/Process&gt;
      &lt;Process xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
         &lt;Object&gt;
            &lt;DatabaseID&gt;$(ASCMDDBNAME)&lt;/DatabaseID&gt;
            &lt;CubeID&gt;$(ASCMDDBNAME)&lt;/CubeID&gt;
            &lt;MeasureGroupID&gt;Fact Internet Sales 1&lt;/MeasureGroupID&gt;
            &lt;PartitionID&gt;Internet_Sales_2002&lt;/PartitionID&gt;
         &lt;/Object&gt;
         &lt;Type&gt;$(PROCESSTYPE)&lt;/Type&gt;
         &lt;WriteBackTableCreation&gt;UseExisting&lt;/WriteBackTableCreation&gt;
      &lt;/Process&gt;
      &lt;Process xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
         &lt;Object&gt;
            &lt;DatabaseID&gt;$(ASCMDDBNAME)&lt;/DatabaseID&gt;
            &lt;CubeID&gt;$(ASCMDDBNAME)&lt;/CubeID&gt;
            &lt;MeasureGroupID&gt;Fact Internet Sales 1&lt;/MeasureGroupID&gt;
            &lt;PartitionID&gt;Internet_Sales_2004&lt;/PartitionID&gt;
         &lt;/Object&gt;
         &lt;Type&gt;$(PROCESSTYPE)&lt;/Type&gt;
         &lt;WriteBackTableCreation&gt;UseExisting&lt;/WriteBackTableCreation&gt;
      &lt;/Process&gt;
      &lt;Process xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
         &lt;Object&gt;
            &lt;DatabaseID&gt;$(ASCMDDBNAME)&lt;/DatabaseID&gt;
            &lt;CubeID&gt;$(ASCMDDBNAME)&lt;/CubeID&gt;
            &lt;MeasureGroupID&gt;Fact Internet Sales 1&lt;/MeasureGroupID&gt;
            &lt;PartitionID&gt;Internet_Sales_2003&lt;/PartitionID&gt;
         &lt;/Object&gt;
         &lt;Type&gt;$(PROCESSTYPE)&lt;/Type&gt;
         &lt;WriteBackTableCreation&gt;UseExisting&lt;/WriteBackTableCreation&gt;
      &lt;/Process&gt;
   &lt;/Parallel&gt;
&lt;/Batch&gt;</pre></td></tr></table></span></div>
                    </content></div>
                  <h5 class="subHeading" xmlns="">process.bat file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>@echo off
call :generate-timestamp
ascmd -S myserver -d "Adventure Works DW" -i process.xmla
         -o process.xml -T process-%timestamp%.csv -Tl medium 
         -v maxparallel=4 processtype=ProcessFull
if ERRORLEVEL 1 goto errseen
goto :EOF
:errseen
echo ** Error seen in processing
goto :EOF

:generate-timestamp
set now_date=%date%
set now_time=%time%
set now_Year=%now_date:~10,4%
set now_Month=%now_date:~4,2%
set now_Day=%now_date:~7,2%
set now_Hour=%now_time:~0,2%
set now_Min=%now_time:~3,2%
if "%now_Hour:~0,1%"==" " set now_Hour=0%now_Hour:~1,1%
set timestamp=%now_year%%now_month%%now_day%_%now_hour%%now_min%
goto :EOF</pre></td></tr></table></span></div>
                      <p xmlns="">Notice that the batch file uses a timestamp in the output file so that multiple runs can be recorded at the same time. </p>
                    </content></div>
                </sections></div>
            </sections></div>
        </sections></div>
      <h3 class="subHeading" xmlns="">Scenario 4: Creating a New Database on a Server</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">In this scenario, you use the <b>ascmd</b> command-line utility to call an XMLA script file (create.xmla) to create a new database on a server. The database name is defined in the XMLA script using a user-defined scripting variable, and value for this variable is defined at the command line using the <b>–v</b> parameter.</p>
        </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">create.xmla file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <p xmlns="">The file was created from SQL Server Management Studio. To create your own file, right-click the database and from the <b>Script</b> menu, click <b>Create</b>.</p>
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Create xmlns="http://schemas.microsoft.com/analysisservices/2003/engine"&gt;
      &lt;ObjectDefinition&gt;
            &lt;Database xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
                  &lt;ID&gt;$(dbname)&lt;/ID&gt;
                  &lt;Name&gt;$(dbname)&lt;/Name&gt;
                  &lt;Description&gt;A Unified Dimensional Model that encompasses the Adventure Works data warehouse.&lt;/Description&gt;
                  &lt;Language&gt;1033&lt;/Language&gt;
                  &lt;Collation&gt;Latin1_General_CI_AS&lt;/Collation&gt;
                  &lt;DataSourceImpersonationInfo&gt;
                     &lt;ImpersonationMode&gt;Default&lt;/ImpersonationMode&gt;
                  &lt;/DataSourceImpersonationInfo&gt;
                  &lt;Dimensions&gt;
                        &lt;Dimension&gt;
                              &lt;ID&gt;Dim Promotion&lt;/ID&gt;
                              &lt;Name&gt;Promotion&lt;/Name&gt;
                              &lt;Annotations&gt;
 . . .</pre></td></tr></table></span></div>
                    </content></div>
                  <h5 class="subHeading" xmlns="">Command-line example:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <p xmlns="">
                        <b>C:\&gt;ascmd -S myserver -i create.xmla -v dbname="My Adventure Works DW"</b>
                      </p>
                      <p xmlns="">In the previous XMLA script, you could also use scripting variables to configure objects such as the connect string to a data source, the server and database name that are used in the data source, or field names in the data source view. </p>
                    </content></div>
                </sections></div>
            </sections></div>
        </sections></div>
      <h3 class="subHeading" xmlns="">Scenario 5: Creating a Cache Warmer Application</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">In this scenario, you use a batch file (cache_warmer.bat) to call the <b>ascmd</b> command-line utility to call several MDX queries that warm the Analysis Services data cache. For example, you might call this batch file by using SQL Server Agent daily at 2:00 A.M. or after your night batch load. In the batch file, you set environment variables for the server, database, and cube names. Because the server and database names specified as environment variables exactly match the names of system-reserved scripting variables, they become the default values for the <b>–S</b> and <b>–d</b> command-line parameters. The user-defined scripting variable for the cube name is used in all the MDX queries.</p>
        </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">query1.mdx file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <p xmlns="">Files: query1.mdx to query6.mdx in the format of query1.txt</p>
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Statement&gt;
SELECT [Measures].[Internet Sales Amount] ON COLUMNS
FROM $(cube)
WHERE [Customer].[Country].&amp;amp;[United States]
&lt;/Statement&gt;</pre></td></tr></table></span></div>
                      <p xmlns="">Create additional query files by replacing [United States] with the other countries in Adventure Works: [Australia], [Canada], [France], [Germany], or [United Kingdom]. </p>
                    </content></div>
                  <h5 class="subHeading" xmlns="">cache_warmer.bat file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>set ascmdserver=myserver
set ascmddbname=Adventure Works DW
set cube=[Adventure Works]

set QUERYDIR=..\queries
set OUTPUTDIR=..\queries
echo -------------------------
set f=
for %%f in (%QUERYDIR%\*.mdx) do (
    call :query %%f
            if ERRORLEVEL 1 goto :EOF
)
echo -------------------------
echo Done.
goto :EOF

:query
echo Query: %1
echo ---------
ascmd -T %OUTPUTDIR%\querylog.txt -Tl duration 
         -Tf text -o %OUTPUTDIR%\%~n1.xml -i %1
echo Errorlevel: %ERRORLEVEL%
echo -------------------------
if ERRORLEVEL 1 goto :errseen
goto :EOF

:errseen
echo -------------------------
echo   ******
echo   ****** ERROR SEEN ******
echo   ******   Exiting    ******
goto :EOF</pre></td></tr></table></span></div>
                    </content></div>
                </sections></div>
            </sections></div>
        </sections></div>
      <h3 class="subHeading" xmlns="">Scenario 6: Creating a Validation Procedure</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">In this scenario, you use the <b>ascmd</b> command-line utility to call several MDX query files (similar to the previous scenario) at the end of a nightly ETL run. You use the <b>–Tl</b> duration parameter to record the duration of each MDX query into a trace file together with directing the MDX script output to a nul file (<b>–o</b> <i>NUL</i>). You could also use the <b>–Tl </b>duration parameter together with recording the execution results into a trace log. Using the <b>ascmd</b> command-line utility in this manner lets you track the length of time required for each MDX query, and to compare these results daily to ensure that values in the same range are being returned. If duration results for a given day are significantly out of range, this might indicate that the results of the ETL run have to be backed out.</p>
        </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">Command-line example:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <p xmlns="">
                        <b>C:\&gt;ascmd -i %queryfile% -o NUL -T querylog.csv -Tl duration</b>
                      </p>
                    </content></div>
                </sections></div>
            </sections></div>
        </sections></div>
      <h3 class="subHeading" xmlns="">Scenario 7: Automating the Building and Training of a Data Mining Model</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">In this scenario, you use the <b>ascmd</b> command-line utility to call a series of DMX statement as follows: </p>
          <ul xmlns=""><li>
              A DMX statement that creates a mining structure (Bike Buyer Structure.DMX) and uses the environment variables to set the server and database names. <br></br>
            </li><li>
              A DMX statement (Clustering_Model.dmx) that adds a clustering mining model to the structure. <br></br>
            </li><li>
              A DMX statement (DT_Model.dmx) that adds a decision tree mining model to the structure. <br></br>
            </li><li>
              A DMX statement (Process Bike Buyer Structure.dmx) to process the mining structure and mining models. <br></br>
            </li></ul>
          <p xmlns="">When you have the mining structure in place, you can use the <b>ascmd</b> command-line utility to call several DMX statements that query the mining structure using different mining models.</p>
        </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <h4 class="subHeading" xmlns="">Create the mining structure</h4><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">Bike Buyer Structure.dmx file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Statement&gt;
CREATE MINING STRUCTURE [Bike Buyer]
(
    [Customer Key] LONG KEY,
    [Age]LONG DISCRETIZED(Automatic,10),
    [Bike Buyer] LONG DISCRETE,
    [Commute Distance] TEXT DISCRETE,
    [Education] TEXT DISCRETE,
    [Gender] TEXT DISCRETE,
    [House Owner Flag] TEXT DISCRETE,
    [Marital Status] TEXT DISCRETE,
    [Number Cars Owned]LONG DISCRETE,
    [Number Children At Home]LONG DISCRETE,
    [Occupation] TEXT DISCRETE,
    [Region] TEXT DISCRETE,
    [Total Children]LONG DISCRETE,
    [Yearly Income] DOUBLE CONTINUOUS
)
&lt;/Statement&gt;</pre></td></tr></table></span></div>
                      <p xmlns="">Command-line example:</p>
                      <p xmlns="">
                        <b>C:\&gt;set ascmdserver=myserver</b>
                      </p>
                      <p xmlns="">
                        <b>C:\&gt;set ascmddbname=Adventure Works DW</b>
                      </p>
                      <p xmlns="">
                        <b>C:\&gt;ascmd -i "Bike Buyer Structure.dmx"</b>
                      </p>
                    </content></div>
                </sections></div>
            </sections></div>
          <h4 class="subHeading" xmlns="">Add a clustering mining model to the structure</h4><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">Clustering_Model.dmx file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Statement&gt;
ALTER MINING STRUCTURE [Bike Buyer]
ADD MINING MODEL [Clustering]
USING Microsoft_Clustering 
&lt;/Statement&gt;</pre></td></tr></table></span></div>
                      <p xmlns="">Command-line example:</p>
                      <p xmlns="">
                        <b>C:\&gt;ascmd -i "Clustering_Model.dmx"</b>
                      </p>
                    </content></div>
                </sections></div>
            </sections></div>
          <h4 class="subHeading" xmlns="">Add a decision tree mining model to the structure</h4><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">DT_Model.dmx file</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Statement&gt;
ALTER MINING STRUCTURE [Bike Buyer]
ADD MINING MODEL [Decision Tree]
(
    [Customer Key],
    [Age],
    [Bike Buyer] PREDICT,
    [Commute Distance],
    [Education],
    [Gender],
    [House Owner Flag],
    [Marital Status],
    [Number Cars Owned],
    [Number Children At Home],
    [Occupation],
    [Region],
    [Total Children],
    [Yearly Income]
) USING Microsoft_Decision_Trees
WITH DRILLTHROUGH
&lt;/Statement&gt;</pre></td></tr></table></span></div>
                    </content></div>
                  <h5 class="subHeading" xmlns="">Command-line example:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <p xmlns="">
                        <b>C:\&gt;ascmd -i "DT_Model.dmx"</b>
                      </p>
                    </content></div>
                </sections></div>
            </sections></div>
          <h4 class="subHeading" xmlns="">Process the mining structure and mining models</h4><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">Process Bike Buyer Structure.dmx file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Statement&gt;
INSERT INTO MINING STRUCTURE [Bike Buyer]
(
    [Customer Key],
    [Age],
    [Bike Buyer],
    [Commute Distance],
    [Education],
    [Gender],
    [House Owner Flag],
    [Marital Status],
    [Number Cars Owned],
    [Number Children At Home],
    [Occupation],
    [Region],
    [Total Children],
    [Yearly Income]
)
OPENQUERY([$(ASCMDDBNAME)],
    'SELECT CustomerKey, Age, BikeBuyer,
             CommuteDistance,EnglishEducation,
             Gender,HouseOwnerFlag,MaritalStatus,
             NumberCarsOwned,NumberChildrenAtHome, 
             EnglishOccupation,Region,TotalChildren,
             YearlyIncome 
      FROM dbo.vTargetMail')
&lt;/Statement&gt;</pre></td></tr></table></span></div>
                    </content></div>
                  <h5 class="subHeading" xmlns="">Command-line example:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <p xmlns="">
                        <b>C:\&gt;ascmd -i "DT_Model.dmx"</b>
                      </p>
                    </content></div>
                </sections></div>
            </sections></div>
          <h4 class="subHeading" xmlns="">Query the structure using the decision tree mining model</h4><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">SELECT_DRILLTHROUGH.dmx file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Statement&gt;
SELECT * 
FROM [Decision Tree].CASES
&lt;/Statement&gt;</pre></td></tr></table></span></div>
                    </content></div>
                  <h5 class="subHeading" xmlns="">BATCH_PREDICTION.dmx file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Statement&gt;
SELECT
   TOP 10
   t.[LastName],
   t.[FirstName],
   [Decision Tree].[Bike Buyer],
   PredictProbability([Bike Buyer])
From
   [Decision Tree]
PREDICTION JOIN
 OPENQUERY([$(ASCMDDBNAME)],
      'SELECT
         [LastName],
         [FirstName],
         [MaritalStatus],
         [Gender],
         [YearlyIncome],
         [TotalChildren],
         [NumberChildrenAtHome],
         [Education],
         [Occupation],
         [HouseOwnerFlag],
         [NumberCarsOwned]
      FROM
         [dbo].[ProspectiveBuyer]
      ') AS t
ON
   [Decision Tree].[Marital Status] = t.[MaritalStatus] AND
   [Decision Tree].[Gender] = t.[Gender] AND
   [Decision Tree].[Yearly Income] = t.[YearlyIncome] AND
   [Decision Tree].[Total Children] = t.[TotalChildren] AND
   [Decision Tree].[Number Children At Home] = t.[NumberChildrenAtHome] AND
   [Decision Tree].[Education] = t.[Education] AND
   [Decision Tree].[Occupation] = t.[Occupation] AND
   [Decision Tree].[House Owner Flag] = t.[HouseOwnerFlag] AND
   [Decision Tree].[Number Cars Owned] = t.[NumberCarsOwned]
WHERE [Decision Tree].[Bike Buyer] =1
ORDER BY PredictProbability([Bike Buyer]) DESC
&lt;/Statement&gt;</pre></td></tr></table></span></div>
                    </content></div>
                  <h5 class="subHeading" xmlns="">SELECT_DISCRETE.dmx file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Statement&gt;
SELECT DISTINCT [Bike Buyer] 
FROM [Decision Tree]
&lt;/Statement&gt;</pre></td></tr></table></span></div>
                    </content></div>
                  <h5 class="subHeading" xmlns="">Command-line example:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <p xmlns="">
                        <b>C:\&gt;ascmd -i SELECT_DRILLTHROUGH.dmx</b>
                      </p>
                      <p xmlns="">
                        <b>C:\&gt;ascmd -i BATCH_PERDICTION.dmx</b>
                      </p>
                      <p xmlns="">
                        <b>C:\&gt;ascmd -i SELECT_DISCRETE.dmx</b>
                      </p>
                    </content></div>
                </sections></div>
            </sections></div>
        </sections></div>
    </sections></div><h1 class="heading">Scenario 8: Clearing the Analysis Services Data Cache</h1><div id="sectionSection8" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">In this scenario, you use the <b>ascmd</b> command-line utility to call an XMLA script (ClearCache.xmla) that clears the Analysis Services data cache between performance runs when doing performance studies. The ClearCache.xmla file contains scripting variables for the database and cube names. This XMLA script is called by a batch file (ClearCache.bat) that specifies the server and instance name, the database name, the input file name, the output file name, and the cube name.</p>
    </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
        </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">ClearCache.xmla file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Batch xmlns="http://schemas.microsoft.com/analysisservices/2003/engine"&gt;
   &lt;ClearCache&gt;
               &lt;Object&gt;
                      &lt;DatabaseID&gt;$(ASCMDDBNAME)&lt;/DatabaseID&gt;
                      &lt;CubeID&gt;$(CUBE)&lt;/CubeID&gt;
               &lt;/Object&gt;
       &lt;/ClearCache&gt;
&lt;/Batch&gt; </pre></td></tr></table></span></div>
                    </content></div>
                  <h5 class="subHeading" xmlns="">ClearCache.bat file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>@echo off
ascmd -S myserver\myinstance -d "Adventure Works DW" -i ClearCache.xmla
         -o ClearCache.xml -v cube="Adventure Works DW"

if ERRORLEVEL 1 goto :errseen
goto :EOF

:errseen
echo **** Error seen ****
echo ********************
goto :EOF</pre></td></tr></table></span></div>
                    </content></div>
                </sections></div>
            </sections></div>
        </sections></div>
      <h3 class="subHeading" xmlns="">Scenario 9: Determining who is currently connected to your server</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">In this scenario, you use the <b>ascmd</b> command-line utility to retrieve the list of active connections on the server. An application might use this information to delay processing until specific users are disconnected, or to send an e-mail to the operators if anyone has a current connection (other than the connection for the nightly batch run).</p>
        </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">connections.xmla file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Discover xmlns="urn:schemas-microsoft-com:xml-analysis"&gt;
   &lt;RequestType&gt;DISCOVER_CONNECTIONS&lt;/RequestType&gt;
   &lt;Restrictions /&gt;
   &lt;Properties&gt;
      &lt;PropertyList&gt;
         &lt;Content&gt;Data&lt;/Content&gt;     &lt;!-- Only the data; no schema --&gt;
      &lt;/PropertyList&gt;
   &lt;/Properties&gt;
&lt;/Discover&gt;</pre></td></tr></table></span></div>
                    </content></div>
                  <h5 class="subHeading" xmlns="">Command-line example:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <p xmlns="">
                        <b>C:\&gt;ascmd -S myserver -i connections.xmla -o current_connections.xml</b>
                      </p>
                    </content></div>
                </sections></div>
            </sections></div>
        </sections></div>
      <h3 class="subHeading" xmlns="">Scenario 10: Is a partition processed and, if so, when was it last processed</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">In this scenario, you use the <b>ascmd</b> command-line utility to determine if a partition has been processed and when it was processed. This information can easily be retrieved because it is stored as a property of the partition object. Thus a DISCOVER_XML_METADATA request can be used to retrieve this information.</p>
        </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">connections.xmla file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;Discover xmlns="urn:schemas-microsoft-com:xml-analysis"&gt;
   &lt;RequestType&gt;DISCOVER_XML_METADATA&lt;/RequestType&gt;
   &lt;Restrictions&gt;
      &lt;RestrictionList&gt;
        &lt;DatabaseID&gt;$(DatabaseID)&lt;/DatabaseID&gt;
        &lt;CubeID&gt;$(CubeID)&lt;/CubeID&gt;
        &lt;MeasureGroupID&gt;$(MeasureGroupID)&lt;/MeasureGroupID&gt;
        &lt;PartitionID&gt;$(PartitionID)&lt;/PartitionID&gt;
      &lt;!-- Ask for just this object referenced --&gt;
      &lt;ObjectExpansion&gt;ReferenceOnly&lt;/ObjectExpansion&gt;
      &lt;/RestrictionList&gt;
   &lt;/Restrictions&gt;
   &lt;Properties&gt;
      &lt;PropertyList&gt;
         &lt;Content&gt;Data&lt;/Content&gt;     &lt;!-- Only the data; no schema --&gt;
      &lt;/PropertyList&gt;
   &lt;/Properties&gt;
&lt;/Discover&gt;</pre></td></tr></table></span></div>
                    </content></div>
                </sections></div>
            </sections></div>
        </sections></div>
    </sections></div><h1 class="heading">Scenario 11: Using the GO Command to Perform a Writeback Operation</h1><div id="sectionSection9" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">In this scenario, you use the <b>ascmd</b> command-line utility to break the writeback into two pieces: change the data and then commit it. Writeback requires the use of the GO command because the two MDX statements required for a writeback operation (the Update Cube and the Commit Transaction statements) must be issued one after the other within the same transaction. MDX does not support issuing them within the same batch.</p>
      <p xmlns="">For this scenario, you need to modify the Adventure Works DW database to support writeback. The existing database does not currently have an example of a cube that supports writeback. To create and verify a cube that supports writeback, perform the following steps:</p>
      <ol xmlns=""><li>
          
            <b>To define a new cube called “Writeback” </b>
          <br></br>
        </li><li>
          Open Business Intelligence Development Studio.<br></br>
        </li><li>
          On the File menu, point to <b>Open</b> then click <b>Analysis Services Database</b>.<br></br>
        </li><li>
          In the <b>Connect to Database</b> dialog box, type your server name in the <b>Server</b> text box, select the <b>Adventure Works DW</b> database in the <b>Database</b> list, and then click <b>OK</b>.<br></br>
        </li><li>
          In the Solution Explorer pane, right-click <b>Cubes</b> and then click <b>New Cube</b>.<br></br>
        </li><li>
          In the Cube Wizard, click <b>Next</b> on the <b>Welcome to the Cube Wizard</b> page, select <b>Build the cube using a data source</b>, clear the <b>Auto build</b> check box, and then click <b>Next</b>.<br></br>
        </li><li>
          Select <b>Adventure Works DW</b> in the <b>Available data source views</b> list on the <b>Select Data Source View</b> page and then click <b>Next</b>.<br></br>
        </li><li>
          On the <b>Identify Fact and Dimension Tables</b> page, select the <b>Fact</b> check box for the <b>FactSalesQuota</b> table and the <b>Dimension</b> check box for the <b>dbo.DimTime</b> and <b>dbo.DimEmployee</b> table, and then click <b>Next</b>.<br></br>
        </li><li>
          dbo.DimTime (dimension is called Date)dbo.DimEmployeeFactSalesQuota (just using the “Sales Amount Quota” measure)<br></br>
        </li><li>
          On the <b>Review Shared Dimensions</b> page, select <b>Date</b> and <b>Employee</b> in the <b>Available Dimensions</b> list, click <b>&gt;</b> to add these dimensions to the <b>Cube dimensions</b> list and then click <b>Next</b>.<br></br>
        </li><li>
          On the <b>Select Measures</b> page, clear the <b>Fact Sales Quota</b> check box, select the <b>Sales Amount Quota</b> check box, and then click <b>Next</b>.<br></br>
        </li><li>
          On the <b>Completing the Wizard</b> page, change the cube name to <b>Writeback</b> and then click <b>Finish</b>.<br></br>
        </li><li>
          
            <b>To enable writeback for the Fact Sales Quota measure group </b>
          <br></br>
        </li><li>
          In cube designer, select the <b>Partitions</b> tab.<br></br>
        </li><li>
          Right-click <b>Fact Sales Quota</b> partition in the partition list and then click <b>Writeback Settings</b>.<br></br>
        </li><li>
          In the <b>Enable Writeback - Fact Sales Quota</b> dialog box, review the default writeback table name and then click <b>OK</b> to create this table and enable writeback for this partition. <br></br>
        </li><li>
          Notice that two partitions now appear: one for the fact table; one for the writeback table. <br></br>
        </li><li>
          
            <b>To process the Writeback cube</b>
          <br></br>
        </li><li>
          Right-click <b>Writeback</b> in the <b>Cubes</b> node in Solution Explorer and click <b>Process</b>. <br></br>
        </li><li>
          Click <b>Yes</b> when prompted to save changes.<br></br>
        </li><li>
          In the <b>Process Cube - Writeback</b> dialog box, click <b>Run</b>.<br></br>
        </li><li>
          If you expand the processing commands, you will see the CREATE TABLE SQL statement used to create the writeback relational table.<br></br>
        </li><li>
          When processing completes, verify that the process succeeded in the <b>Status</b> box, and then click <b>Close</b>.<br></br>
        </li><li>
          Click Close again to close the <b>Process Partition - WriteTable_Fact Sales Quota</b> dialog box.<br></br>
        </li><li>
          Close Business Intelligence Development Studio.<br></br>
        </li><li>
          
            <b>To verify that writeback is working</b>
          <br></br>
        </li><li>
          Open SQL Server Management Studio.<br></br>
        </li><li>
          Connect to your server, and then in <b>Object Explorer</b>, expand <b>Databases</b>, right-click <b>Adventure Works DW</b>, point to <b>New Query</b> and then click <b>MDX</b>.<br></br>
        </li><li>
          In the MDX query window, execute the following MDX query to return the current sales quote for Q1FY2002 and Stephen Y. Jiang:<br></br>
          <div class="code"><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>/* Employee 272 is [Stephen Y. Jiang]*/
SELECT [Measures].[Sales Amount Quota] ON COLUMNS
FROM [Writeback]
WHERE ([Employee].[Employee].[Stephen Y. Jiang],[Date].[Calendar].[Calendar Quarter].[Q1 CY 2002])</pre></td></tr></table></span></div>
        </li><li>
          Modify the cell to return $2,200 by issuing the following MDX statement:<br></br>
          <div class="code"><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>UPDATE CUBE [Writeback]
SET ([Employee].[Employee].[Stephen Y. Jiang],
[Date].[Calendar].[Calendar Quarter].[Q1 CY 2002]) = 2200</pre></td></tr></table></span></div>
        </li><li>
          Commit the transaction by executing the following MDX statement:<br></br>
          <div class="code"><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>COMMIT TRANSACTION</pre></td></tr></table></span></div>
          At this point, you can examine the “dbo.WriteTable_Fact Sales Quota” table in the Adventure Works DW relational database to see what writeback has actually done for the cell. If you do, you will notice that it is the delta (-88800) that is written to this relational table. The original fact table is unchanged.<br></br>
        </li></ol>
    </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
        </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                  <h5 class="subHeading" xmlns="">writeback.mdx file:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>/* What is the existing value? */
SELECT [Measures].[Sales Amount Quota] ON COLUMNS
FROM [Writeback]
WHERE ([Employee].[Employee].&amp;[272],
[Date].[Calendar].[Calendar Quarter].&amp;[2002]&amp;[1])
GO
/* Update the cube with a new value */
UPDATE CUBE [Writeback]
SET ([Employee].[Employee].&amp;[272],
[Date].[Calendar].[Calendar Quarter].&amp;[2002]&amp;[1]) = 33000 /* some different value */
GO
/* Commit it */
Commit Transaction
GO
/* See what the updated value is */
SELECT [Measures].[Sales Amount Quota] ON COLUMNS
FROM [Writeback]
WHERE ([Employee].[Employee].&amp;[272],
[Date].[Calendar].[Calendar Quarter].&amp;[2002]&amp;[1])
GO</pre></td></tr></table></span></div>
                    </content></div>
                  <h5 class="subHeading" xmlns="">Command-line example:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <p xmlns="">
                        <b>C:\&gt;ascmd -S myserver -d "Adventure Works DW" -i writeback.mdx -o writeback_result.xml -v cube="[Writeback]"</b>
                      </p>
                    </content></div>
                  <h5 class="subHeading" xmlns="">Writeback_result.xml:</h5><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
                      <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>&lt;multiple-batches&gt;
   &lt;return xmlns="urn:schemas-microsoft-com:xml-analysis"&gt;
      &lt;root xmlns= . . .&gt;
         &lt;...metadata about the result set...&gt;
&lt;CellData xmlns="urn:schemas-microsoft-com:xml-analysis:mddataset"&gt;
  &lt;Cell CellOrdinal="0"&gt;
     &lt;Value xsi:type="xsd:double" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;0&lt;/Value&gt; 
     &lt;FmtValue&gt;2200&lt;/FmtValue&gt; 
  &lt;/Cell&gt;
&lt;/CellData&gt;
      &lt;/root&gt;
   &lt;/return&gt;
   &lt;return xmlns="urn:schemas-microsoft-com:xml-analysis"&gt;
      &lt;root xmlns="urn:schemas-microsoft-com:xml-analysis:empty" /&gt; 
   &lt;/return&gt;
   &lt;return xmlns="urn:schemas-microsoft-com:xml-analysis"&gt;
      &lt;root xmlns="urn:schemas-microsoft-com:xml-analysis:empty" /&gt; 
   &lt;/return&gt;
   &lt;return xmlns="urn:schemas-microsoft-com:xml-analysis"&gt;
      &lt;root xmlns= . . .&gt;
         &lt;...metadata about the result set...&gt;
&lt;CellData xmlns="urn:schemas-microsoft-com:xml-analysis:mddataset"&gt;
  &lt;Cell CellOrdinal="0"&gt;
     &lt;Value xsi:type="xsd:double" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;0&lt;/Value&gt; 
     &lt;FmtValue&gt;33000&lt;/FmtValue&gt; 
  &lt;/Cell&gt;
&lt;/CellData&gt;
      &lt;/root&gt;
   &lt;/return&gt;
&lt;/multiple-batches&gt;</pre></td></tr></table></span></div>
                      <p xmlns="">Notice that there are two empty result sets in the middle for the UPDATE CUBE statement and the COMMIT TRANSACTION statement.</p>
                    </content></div>
                </sections></div>
            </sections></div>
        </sections></div>
    </sections></div><!--[if gte IE 5]>
			<tool:tip element="seeAlsoToolTip" avoidmouse="false"/><tool:tip element="languageFilterToolTip" avoidmouse="false"/><tool:tip element="roleInfoSpan" avoidmouse="false"/>
		<![endif]--></div>
      <div id="footer">
        
			
			© 2007 Microsoft Corporation. All rights reserved.
		</a>
 	
      </div>
    </div>
  </body>
</html>